/**
 * <p>Title: Cell Class</p>
 * <p>Description: CS 343 Project</p>
 * @author Quintin Stolpe
 * @email quintin.stolpe@my.uwrf.edu
 * @date Dec 3 2012
*/

package maze;


public class Segment
{

	int startX;
	int startY;
	int endX;
	int endY;

	boolean dx;

	int min;
	int max;

	public Segment(int sX, int sY, boolean aDx)
	{
		startX = sX;
		startY = sY;

		dx = aDx;

	}

	public void setEnd(int x, int y)
	{
		endX = x;
		endY = y;
		
		if (dx)
		{
			if (startX == endX)
			{
				System.out.println("error in Segment.setEnd");
			}
			if (startX > endX)
			{
				max = startX;
				min = endX;
			}
			else
			{
				max = endX;
				min = startX;
			}
		}
		else
		{
			if (startY == endY)
			{
				System.out.println("Error in Segement.setEnd()");
			}
			if (startY > endY)
			{
				max = startY;
				min = endY;
			}
			else
			{
				max = endY;
				min = startY;
			}
		}
	}

	public boolean contains(int x, int y)
	{
		if (dx)
		{
			return (y == startY && x >= min && x <= max);
		}

		return (x == startX && y >= min && y <= max);
	}
	
}
